package com.qianfeng.smartmeeting.controller.user;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import com.qianfeng.smartmeeting.util.JwtUtil;
import com.qianfeng.smartmeeting.util.Md5Util;
import com.qianfeng.smartmeeting.util.PageUtils;
import com.qianfeng.smartmeeting.util.R;
import org.apache.catalina.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.web.bind.annotation.*;

import com.qianfeng.smartmeeting.entity.UserEntity;
import com.qianfeng.smartmeeting.service.UserService;




/**
 * 
 *
 * @author baixiaofei
 * @email 2053989588@qq.com
 * @date 2025-07-02 15:06:43
 */
@RestController
@RequestMapping("smartmeeting/user/user")
@PreAuthorize("hasRole('USER')")
public class UserController {
    @Autowired
    private UserService userService;

    @Autowired
    private AuthenticationManager authenticationManager;


    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("smartmeeting:user:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = userService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{userId}")
    //@RequiresPermissions("smartmeeting:user:info")
    public R info(@PathVariable("userId") Integer userId){
		UserEntity user = userService.getById(userId);

        return R.ok().put("user", user);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("smartmeeting:user:save")
    public R save(@RequestBody UserEntity user){
		userService.save(user);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("smartmeeting:user:update")
    public R update(@RequestBody UserEntity user){
		userService.updateById(user);
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("smartmeeting:user:delete")
    public R delete(@RequestBody Integer[] userIds){
		userService.removeByIds(Arrays.asList(userIds));

        return R.ok();
    }

}
